home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg2.cab / ooo2wordml.xsl < prev    next >
Extensible Markup Language  |  2005-09-10  |  15KB  |  227 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: ooo2wordml.xsl,v $
  7.  
  8.     $Revision: 1.9 $
  9.  
  10.     last change: $Author: rt $ $Date: 2005/09/08 22:05:06 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg   dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
  37.     <xsl:output method="xml" indent="no" encoding="UTF-8" version="1.0" standalone="yes"/>
  38.     <xsl:include href="../../common/measure_conversion.xsl"/>
  39.     <xsl:include href="../common/ooo2ms_docpr.xsl"/>
  40.     <xsl:include href="ooo2wordml_settings.xsl"/>
  41.     <xsl:include href="ooo2wordml_border.xsl"/>
  42.     <xsl:include href="ooo2wordml_page.xsl"/>
  43.     <xsl:include href="ooo2wordml_text.xsl"/>
  44.     <xsl:include href="ooo2wordml_list.xsl"/>
  45.     <xsl:include href="ooo2wordml_field.xsl"/>
  46.     <xsl:include href="ooo2wordml_table.xsl"/>
  47.     <xsl:include href="ooo2wordml_draw.xsl"/>
  48.     <xsl:include href="ooo2wordml_path.xsl"/>
  49.     <xsl:key name="paragraph-style" match="style:style[@style:family='paragraph']" use="@style:name"/>
  50.     <xsl:key name="text-style" match="style:style[@style:family='text']" use="@style:name"/>
  51.     <xsl:key name="section-style" match="style:style[@style:family='section']" use="@style:name"/>
  52.     <xsl:key name="master-page" match="style:master-page" use="@style:name"/>
  53.     <xsl:key name="page-layout" match="style:page-layout" use="@style:name"/>
  54.     <xsl:key name="slave-style" match="style:style[string-length(normalize-space(@style:master-page-name)) > 0]" use="@style:name"/>
  55.     <xsl:key name="list-style" match="office:styles/text:list-style | office:automatic-styles/text:list-style" use="@style:name"/>
  56.     <xsl:key name="graphics-style" match="style:style[@style:family='graphic']" use="@style:name"/>
  57.     <xsl:template match="/">
  58.         <xsl:apply-templates select="office:document"/>
  59.     </xsl:template>
  60.     <xsl:template match="office:document">
  61.         <xsl:processing-instruction name="mso-application">progid="Word.Document"</xsl:processing-instruction>
  62.         <xsl:variable name="embeddedObjPresent">
  63.             <xsl:choose>
  64.                 <xsl:when test="//draw:object-ole[1]">yes</xsl:when>
  65.                 <xsl:otherwise>no</xsl:otherwise>
  66.             </xsl:choose>
  67.         </xsl:variable>
  68.         <w:wordDocument xml:space="preserve" w:embeddedObjPresent="{$embeddedObjPresent}">
  69.             <xsl:apply-templates select="office:meta"/>
  70.             <xsl:apply-templates select="office:font-face-decls"/>
  71.             <xsl:if test="office:styles/text:outline-style | office:styles/text:list-style | office:automatic-styles/text:list-style">
  72.                 <xsl:call-template name="ListStyles"/>
  73.             </xsl:if>
  74.             <w:styles>
  75.                 <xsl:apply-templates select="office:styles"/>
  76.                 <xsl:apply-templates select="office:automatic-styles"/>
  77.                 <xsl:call-template name="add_hyperlink_style"/>
  78.                 <!--add for hyperlink character style G.Y.-->
  79.                 <xsl:call-template name="add_comments_style"/>
  80.                 <!--add for comments style G.Y.-->
  81.             </w:styles>
  82.             <xsl:call-template name="export-oledata"/>
  83.             <xsl:apply-templates select="office:settings"/>
  84.             <xsl:apply-templates select="office:body"/>
  85.         </w:wordDocument>
  86.     </xsl:template>
  87.     <xsl:template match="office:body">
  88.         <xsl:call-template name="page-background"/>
  89.         <xsl:apply-templates select="office:text"/>
  90.     </xsl:template>
  91.     <xsl:template match="office:font-face-decls">
  92.         <!-- get default font from default paragraph properties -->
  93.         <w:fonts>
  94.             <xsl:variable name="default-paragraph-properties" select="/office:document/office:styles/style:default-style[@style:family = 'paragraph']/style:paragraph-properties"/>
  95.             <w:defaultFonts w:ascii="{$default-paragraph-properties/@style:font-name}" w:h-ansi="{$default-paragraph-properties/@style:font-name}" w:fareast="{$default-paragraph-properties/@style:font-name-asian}" w:cs="{$default-paragraph-properties/@style:font-name-complex}"/>
  96.             <xsl:for-each select="style:font-face">
  97.                 <w:font w:name="{@style:name}">
  98.                     <xsl:if test="@style:font-charset = 'x-symbol'">
  99.                         <w:charset w:val="02"/>
  100.                     </xsl:if>
  101.                     <xsl:choose>
  102.                         <xsl:when test="@style:font-family-generic = 'swiss'">
  103.                             <w:family w:val="Swiss"/>
  104.                         </xsl:when>
  105.                         <xsl:when test="@style:font-family-generic = 'modern'">
  106.                             <w:family w:val="Modern"/>
  107.                         </xsl:when>
  108.                         <xsl:when test="@style:font-family-generic = 'roman'">
  109.                             <w:family w:val="Roman"/>
  110.                         </xsl:when>
  111.                         <xsl:when test="@style:font-family-generic = 'script'">
  112.                             <w:family w:val="Script"/>
  113.                         </xsl:when>
  114.                         <xsl:when test="@style:font-family-generic = 'decorative'">
  115.                             <w:family w:val="Decorative"/>
  116.                         </xsl:when>
  117.                         <xsl:when test="@style:font-family-generic = 'system'">
  118.                             <w:family w:val="System"/>
  119.                         </xsl:when>
  120.                         <xsl:otherwise>
  121.                             <w:family w:val="System"/>
  122.                         </xsl:otherwise>
  123.                     </xsl:choose>
  124.                     <w:pitch w:val="{@style:font-pitch}"/>
  125.                 </w:font>
  126.             </xsl:for-each>
  127.         </w:fonts>
  128.     </xsl:template>
  129.     <xsl:template match="office:styles | office:automatic-styles">
  130.         <xsl:for-each select="*[(name()='style:style' or name()='style:default-style') and (@style:family= 'paragraph' or @style:family= 'text' or @style:family='table')]">
  131.             <xsl:variable name="style-name">
  132.                 <xsl:choose>
  133.                     <xsl:when test="name() = 'style:default-style'">
  134.                         <xsl:value-of select="concat('default-', @style:family, '-style')"/>
  135.                     </xsl:when>
  136.                     <xsl:otherwise>
  137.                         <xsl:value-of select="@style:name"/>
  138.                     </xsl:otherwise>
  139.                 </xsl:choose>
  140.             </xsl:variable>
  141.             <w:style w:styleId="{$style-name}">
  142.                 <xsl:choose>
  143.                     <xsl:when test="@style:family = 'paragraph'">
  144.                         <xsl:attribute name="w:type">paragraph</xsl:attribute>
  145.                     </xsl:when>
  146.                     <xsl:when test="@style:family = 'text'">
  147.                         <xsl:attribute name="w:type">character</xsl:attribute>
  148.                     </xsl:when>
  149.                     <xsl:when test="@style:family = 'table'">
  150.                         <xsl:attribute name="w:type">table</xsl:attribute>
  151.                     </xsl:when>
  152.                 </xsl:choose>
  153.                 <xsl:if test="name() = 'style:default-style'">
  154.                     <xsl:attribute name="w:default">on</xsl:attribute>
  155.                 </xsl:if>
  156.                 <xsl:choose>
  157.                     <xsl:when test="@style:parent-style-name">
  158.                         <w:basedOn w:val="{@style:parent-style-name}"/>
  159.                     </xsl:when>
  160.                     <xsl:when test="name() = 'style:style' and @style:family= 'paragraph'">
  161.                         <w:basedOn w:val="{concat('default-', @style:family, '-style')}"/>
  162.                     </xsl:when>
  163.                 </xsl:choose>
  164.                 <w:name w:val="{$style-name}"/>
  165.                 <xsl:if test="parent::office:automatic-styles">
  166.                     <w:hidden w:val="on"/>
  167.                 </xsl:if>
  168.                 <xsl:if test="@style:next-style-name">
  169.                     <w:next w:val="{@style:next-style-name}"/>
  170.                 </xsl:if>
  171.                 <xsl:choose>
  172.                     <xsl:when test="@style:family = 'paragraph'">
  173.                         <xsl:apply-templates select="style:paragraph-properties" mode="paragraph"/>
  174.                     </xsl:when>
  175.                     <xsl:when test="@style:family = 'table'">
  176.                         <w:tblPr>
  177.                             <xsl:apply-templates select="style:table-properties" mode="table"/>
  178.                         </w:tblPr>
  179.                     </xsl:when>
  180.                 </xsl:choose>
  181.                 <xsl:apply-templates select="style:text-properties" mode="character"/>
  182.             </w:style>
  183.         </xsl:for-each>
  184.     </xsl:template>
  185.     <xsl:template match="office:text">
  186.         <w:body>
  187.             <xsl:apply-templates select="text:p | text:h | text:section | text:unordered-list | text:ordered-list | text:list |table:table"/>
  188.             <xsl:variable name="paragraph-heading-table" select=".//*[name() = 'text:p' or name() = 'text:h' or name() = 'table:table']"/>
  189.             <xsl:variable name="page" select="$paragraph-heading-table[key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])]"/>
  190.             <w:sectPr>
  191.                 <!--w:type w:val="continuous"/ -->
  192.                 <xsl:apply-templates select="/office:document/office:styles/text:footnotes-configuration">
  193.                     <xsl:with-param name="within-section" select="'yes'"/>
  194.                 </xsl:apply-templates>
  195.                 <xsl:apply-templates select="/office:document/office:styles/text:endnotes-configuration">
  196.                     <xsl:with-param name="within-section" select="'yes'"/>
  197.                 </xsl:apply-templates>
  198.                 <xsl:choose>
  199.                     <xsl:when test="count($page) > 0">
  200.                         <xsl:apply-templates select="key('master-page', key( 'slave-style', $page[last()]/@*[name()='text:style-name' or name()='table:style-name'])/@style:master-page-name)"/>
  201.                         <xsl:if test="key( 'slave-style', $page[last()]/@*[name()='text:style-name' or name()='table:style-name'])/style:paragraph-properties/@style:page-number">
  202.                             <!-- in M$ word the header and footer associate with the w:sectPr, but in StarOffice writer the header and footer associate with the style:master-page -->
  203.                             <xsl:variable name="pagenumber_start">
  204.                                 <xsl:value-of select=" key( 'slave-style', $page[last()]/@*[name()='text:style-name' or name()='table:style-name'])/style:paragraph-properties/@style:page-number"/>
  205.                             </xsl:variable>
  206.                             <xsl:if test=" number($pagenumber_start)  > 0 ">
  207.                                 <w:pgNumType w:start="{$pagenumber_start}"/>
  208.                             </xsl:if>
  209.                             <!-- comment out the below line to enable the header and footer display normally when style:page-number =0  -->
  210.                             <!-- w:pgNumType w:start="{key( 'slave-style', $page[last()]/@*[name()='text:style-name' or name()='table:style-name'])/style:paragraph-properties/@style:page-number}"/-->
  211.                         </xsl:if>
  212.                     </xsl:when>
  213.                     <xsl:otherwise>
  214.                         <xsl:apply-templates select="/office:document/office:master-styles/style:master-page[1]"/>
  215.                     </xsl:otherwise>
  216.                 </xsl:choose>
  217.                 <xsl:if test="$paragraph-heading-table[last()]/ancestor::text:section">
  218.                     <xsl:apply-templates select="key('section-style',$paragraph-heading-table[last()]/ancestor::text:section[1]/@text:style-name)" mode="section"/>
  219.                 </xsl:if>
  220.             </w:sectPr>
  221.         </w:body>
  222.     </xsl:template>
  223.     <xsl:template match="text:section">
  224.         <xsl:apply-templates select="text:p | text:h | text:section | text:unordered-list | text:ordered-list | text:list | table:table"/>
  225.     </xsl:template>
  226. </xsl:stylesheet>
  227.